<!--button.vue-->
<template>
	<el-button type="primary" @click="onClick">{{ props[0].fields[3].value.value }}</el-button>
</template>

<script>
import bus from '@/eventBus/index'
import { mapGetters, mapMutations } from 'vuex'
export default {
	name: 'CButton',
	props: {
		props: {
			type: Array,
			default: function () {
				return [
					{
						fields: [],
					},
				]
			},
		},
		parentnode: {},
	},
	computed: {
		...mapGetters(['projectDataInfo']),
	},
	methods: {
		onClick() {
			let arr = []
			for (const item in this.parentnode.$refs) {
				arr.push(item)
			}
			const newprojectDataInfo = JSON.parse(JSON.stringify(this.projectDataInfo))
			newprojectDataInfo.pages[0].elements[0].props[1].fields[0].value.dataJson.json = '[{"X":"冀东","Y":2}]'
			this.$store.dispatch('setProjectDataInfo', newprojectDataInfo)
			let eventData = this.props[1].fields[0].value.value
			bus.$emit('button-click', eventData)
		},
	},
}
</script>
